<template>
  <div class="payview">
    <van-nav-bar left-text="" title="确认订单" left-arrow @click-left="back()">
      <template #right>
        <van-icon name="ellipsis" size="18" />
      </template>
    </van-nav-bar>

    <van-cell-group>
      <van-cell title="请添加地址" value="＞" />
    </van-cell-group>

   <van-submit-bar
      :price="totalMoney()"
      :disabled="check_goods.length <= 0"
      @submit="onSubmit"
      
    >
      <template #button>
        <div class="buy" @click="gopay()">去结算<span>({{totalCount()}})</span></div>
      </template>
      <van-checkbox v-model="isCheckAll" @change="allCheckHandle"
        >全选</van-checkbox
      >
    </van-submit-bar>
    
  </div>
</template>

<script>
import BuydownbarCom from "@/components/BuydownbarCom";
import { SubmitBar } from "vant";
import { Card } from "vant";

Vue.use(SubmitBar);
Vue.use(Card);
import Vue from "vue";
import { Cell, CellGroup } from "vant";

Vue.use(Cell);
Vue.use(CellGroup);
export default {
   
  data() {
    return {
      buylist: [],
       check_goods: []
    };
  },
  components: {
    BuydownbarCom,
  },
  methods: {
    back() {
      this.$router.go(-1);
    },
     totalCount() {
      return this.buylist.reduce((sum, item) => {
        return sum + (item.isChecked ? item.num : 0);
      }, 0);
    },
    totalMoney() {
     
      return this.buylist.reduce((sum, item) => {
        return sum +  parseInt((item.isChecked ? item.num * item.originprice : 0)+'00'+'.00')
      }, 0);
      
    },
  },
  created() {
    this.buylist = this.$route.params.promsg;
    console.log(this.$route.params.promsg);
  },
};
</script>

<style>
</style>